How to use unsigned shift (>>>) operator In Javascript
Round a number to towards zero.
Syntax:
let = value >>> 0;
Example: Here is an example of the above-explained method.
javascript
// float value is 5.68; let x = 5.68; // It is same as we are dividing the value by 1. let z = x >>> 0; console.log( "Converted value of " + x + " is " + z); |
Output:
Converted value of 5.68 is 5
How to convert a float number to the whole number in JavaScript ?
In this article, we will convert a float number to a whole number in JavaScript.
Below are various methods to convert float numbers to whole numbers in JavaScript:
Table of Content
- Math.floor (floating argument):
- Math.ceil (floating argument)
- Math.round (floating argument)
- Math.trunc (floating argument)
- parseInt (floating argument)
- double bitwise not (~~) operator
- JavaScript bitwise OR (|) Operator
- Using shift (>>) operator
- Using unsigned shift (>>>) operator
- By subtracting the fractional part
- Using XOR (^) operator Syntax:
Contact Us